﻿using System;
using WFC.BL.Services;
using WFC.BL.Services.Interfaces;
using WFC.BL.Interfaces.DomainModels;

namespace WFC.WebSite.Views
{
    public class CmsHtmlControlPresenter
    {

        private ICmsHtmlControlView View { get; set; }
        private IContentService Service { get; set; }

        /// <summary>
        /// Default constructor
        /// </summary>
        /// <param name="view"></param>
        public CmsHtmlControlPresenter(ICmsHtmlControlView view)
        {
            View = view;
            View.OnControllerLoad += OnLoad;

            Service = new ContentService();
        }

        private void OnLoad(object sender, EventArgs e)
        {
            if (View.ContentId < 1) return;

            IContentMaintainable model = Service.ReadContentsById(View.ContentId);
            View.HtmlContent = model.HtmlContent;
        }

    }
}
